#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Django settings for pytest project.

import os.path

#===============================================================================
# 自定义参数
#===============================================================================
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = ()
#定义项目应用名称,为memcache，数据库表做前缀之用
PROJECT_NAME = 'demo'
MEMCACHE_URL = ['127.0.0.1:11211']
MEMCACHE_PREFIX = PROJECT_NAME
DB_PREFIX = ''
DATABASES = {'default': {
        'ENGINE': 'django.db.backends.mysql',   # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'sdcms',                        # Or path to database file if using sqlite3.
        'USER': 'sdcms',                        # Not used with sqlite3.
        'PASSWORD': 'cms821121',                # Not used with sqlite3.
        'HOST': 'localhost',                    # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '3306',                         # Set to empty string for default. Not used with sqlite3.
    }}
#===============================================================================
# 系统参数，建议不要更改
#===============================================================================
HERE = os.path.dirname(__file__)
TIME_ZONE = 'Asia/Shanghai'
LANGUAGE_CODE = 'zh_CN'
SITE_ID = 1
USE_I18N = True
USE_L10N = True
MEDIA_ROOT = os.path.join(HERE, 'media').replace('\\','/')
MEDIA_URL = '/media/'
#STATIC_ROOT = os.path.join(HERE, 'static').replace('\\','/')
STATIC_ROOT = ""
STATIC_URL = '/static/'

LOCALE_PATHS =  (os.path.join(HERE,'locale').replace('\\','/'),)

#ADMIN_MEDIA_PREFIX = '/static/admin/'

STATICFILES_DIRS = (os.path.join(HERE,'static').replace('\\','/'),)

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)


# Make this unique, and don't share it with anybody.
SECRET_KEY = '$xz+blpbdqg4mgx4cj6@4o-5zy86*lzll!$ln4g%ki#e(vh&8s'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
    
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    #让系统支持session
    'django.contrib.sessions.middleware.SessionMiddleware',
    #'django.middleware.csrf.CsrfViewMiddleware',
    #'django.contrib.auth.middleware.AuthenticationMiddleware',
    #'django.contrib.messages.middleware.MessageMiddleware',
    #整站缓存
    #'django.middleware.cache.CacheMiddleware',
    #页面也说传输
    'django.middleware.gzip.GZipMiddleware',
    #事务管理
    #不用全局的事务控制
    #"django.middleware.transaction.TransactionMiddleware",
)

ROOT_URLCONF = 'sd.urls'
TEMPLATE_DIRS = (os.path.join(HERE, 'templates').replace('\\','/'),)
INSTALLED_APPS = (
    #'django.contrib.auth',
    #'django.contrib.contenttypes',
    #让系统支持seesion，用SESSION_ENGINE指定那种session引擎
    #'django.contrib.sessions',
    #'django.contrib.sites',
    #'django.contrib.messages',
    #静态文件处理应用，发布程序时需关闭，这种方法比较慢
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    # 'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
    'sd.cms',
)

#配置seesion引擎，现在配置基于cache
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
#设置session的失效时间
SESSION_COOKIE_AGE= 60*60*2
#缓存方案，可以配置内存级，数据库级，文件级；当前系统配置的为内存级的memcached
#配置memcached
CACHES = {'default': {
            'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
            'LOCATION': MEMCACHE_URL[0],
    }}
#缓存的时间
CACHE_MIDDLEWARE_SECONDS = 60*60*2
#缓存key值前缀
CACHE_MIDDLEWARE_KEY_PREFIX = PROJECT_NAME

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'console':{
            'level':'DEBUG',
            'class':'logging.StreamHandler',
        },
    },
    'loggers': {
        'django.db.backends': {
            'handlers': ['console'],
            'propagate': True,
            'level':'DEBUG',
        },
    }
}

#===============================================================================
# LOGGING = {
#    'version': 1,
#    'disable_existing_loggers': False,
#    'handlers': {
#        'mail_admins': {
#            'level': 'ERROR',
#            'class': 'django.utils.log.AdminEmailHandler'
#        }
#    },
#     'loggers': {
#        'django.request': {
#            'handlers': ['mail_admins'],
#            'level': 'ERROR',
#            'propagate': True,
#        },
#    }
# }
#===============================================================================